using System; 
using UnityEngine;

public static class BlockBannerAnchor
{
    public static float GetBannerPositionY()
    {
        if (!BlockBannerAnchor.isSet)
        {
            BlockBannerAnchor.totalpoint = BlockBannerAnchor.GetScreenSize();
            BlockBannerAnchor.bannerHeightToWorldPointY += 0.6f;
            BlockBannerAnchor.isSet = true;
        }
        //if (UncleBill.IsRich)
        //{
        //    return -Mathf.Abs(BlockBannerAnchor.totalpoint.y) / 2f + 0.6f;
        //}
        return -Mathf.Abs(BlockBannerAnchor.totalpoint.y) / 2f + BlockBannerAnchor.bannerHeightToWorldPointY;
    }

    private static Vector2 GetScreenSize()
    {
        Vector3 vector = Camera.main.ViewportToWorldPoint(new Vector3(0f, 0f, Camera.main.nearClipPlane));
        Vector3 vector2 = Camera.main.ViewportToWorldPoint(new Vector3(1f, 1f, Camera.main.nearClipPlane));
        return new Vector2(vector2.x - vector.x, vector2.y - vector.y);
    }

    public static float GetTopPositionY()
    {
        return Camera.main.ViewportToWorldPoint(new Vector3(1f, 1f, Camera.main.nearClipPlane)).y-1.5f;
    }

    public static float GetLeftPositionX()
    {
        return Camera.main.ViewportToWorldPoint(new Vector3(0f, 1f, Camera.main.nearClipPlane)).x;
    }

    public static float GetRightPositionX()
    {
        return Camera.main.ViewportToWorldPoint(new Vector3(1f, 1f, Camera.main.nearClipPlane)).x;
    }

    public static float GetWidgetInterval(GameObject topMask, GameObject bottomMask, float originalwidgetInterval)
    {
        float num = Mathf.Abs(Scene.CurrentScene().transform.InverseTransformPoint(topMask.transform.position).y - 2f) + Mathf.Abs(bottomMask.transform.localPosition.y);
        int num2 = (int)(num / originalwidgetInterval);
        return num / (float)(num2 + 1);
    }

    public static void SetBottomPosition(GameObject bottomMask, GameObject bottom)
    {
        float bannerPositionY = BlockBannerAnchor.GetBannerPositionY();
        Vector3 localPosition = bottomMask.transform.localPosition;
        localPosition.y = bannerPositionY + 2f;
        bottomMask.transform.localPosition = localPosition;
        bottom.transform.localPosition = new Vector3(bottom.transform.localPosition.x, bannerPositionY, bottom.transform.localPosition.z);
    }

    private static bool isSet = false;

    private static Vector2 totalpoint = Vector2.zero;

    private static float bannerHeightToWorldPointY = 0f;

    private const float ANDROID_NAVIGATIONBAR_HEIGHT = 0.6f;
}
